@extends("admin.layout.main")

@section("content")

    <style>
        table thead tr th {
            text-align: center
        }

        table tbody tr td {
            text-align: center
        }
    </style>
    <div class="page-header">
        <h1>
            创客提现
        </h1>
    </div>
    <div class="page-header">
        <form action="">
            <input type="checkbox" id="all_check" onclick="all_select(this)">
            全选
            <label style="margin-left: 20px;">
                申请日期：
                <input type="text" id="start_time" name="start_time" value="{{ $where['start_time'] }}">
                至
                <input type="text" id="end_time" name="end_time" value="{{ $where['end_time'] }}">
            </label>
            <label>
                状态：
                <select name="status" id="">
                    <option value="0">全部</option>
                    <option value="3" @if($where['status']==3) selected @endif>申请中</option>
                    <option value="1" @if($where['status']==1) selected @endif>转账成功</option>
                    <option value="2" @if($where['status']==2) selected @endif>转账失败</option>
                </select>
            </label>
            <button class="btn btn-xs btn-primary">搜索</button>
        </form>
    </div>


    <!-- div.table-responsive -->

    <!-- div.dataTables_borderWrap -->
    <div>
        <table id="simple-table" class="table table-striped table-bordered table-hover">
            <thead>
            <tr>
                <th>用户ID</th>
                <th>创客昵称</th>
                <th>申请时间</th>
                <th>申请金额</th>
                {{--<th>微信号</th>--}}
                <th>开户行名称</th>
                {{--<th>开户地</th>--}}
                {{--<th>支行名称</th>--}}
                <th>银行帐号</th>
                <th>持卡人</th>
                <th>手机帐号</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
            </thead>

            <tbody>
                @foreach($data as $v)
                    <tr>
                        <td> @if($v->status==3)<input type="checkbox" name="ids[]" value="{{ $v->id }}" style="margin-right: 5px" onclick="check_all_select(this)">@endif{{ $v->user['id'] }}</td>
                        <td>{{ $v->user['name'] }}</td>
                        <td>{{ $v->created_at }}</td>
                        <td>{{ $v->cash }}</td>
                        {{--<td>{{ $v->remark_info }}</td>--}}
                        <td>{{ $v->bank['account_branch_name'] }}</td>
                        {{--<td>广东省广州市荔湾区</td>--}}
                        <td>{{ $v->bank['account_code'] }}</td>
                        <td>{{ $v->bank['account_name'] }}</td>
                        {{--<td>@if(isset($v->user->bankAccount)){{ $v->user->bankAccount->bank->account_name }}@endif</td>--}}
                        <td>{{ $v->user['mobile'] }}</td>
                        <td>{{ $statusArr[$v->status] }}</td>
                        <td>
                            @if($v->status==3)
                            <a class="btn btn-xs btn-success" onclick="confirm_handle('确认已转账?',one_check,'',{'ids':'{{ $v->id }}','status':1})">已转账</a>
                            <a class="btn btn-xs btn-danger" onclick="confirm_handle('确认转账失败?',one_check,'',{'ids':'{{ $v->id }}','status':2})">转账失败</a>
                            @endif
                        </td>
                    </tr>
                @endforeach
            </tbody>
        </table>
        <div class="pagination pagination-centered">
            <button class="btn btn-xs btn-success" onclick="confirm_handle('确认已转账?',batch_check,'',{'status':1})">已转账</button>
            <button class="btn btn-xs btn-danger" onclick="confirm_handle('确认转账失败?',batch_check,'',{'status':2})">转账失败</button>
            {{ $data->appends($where)->links('admin.layout.page') }}
        </div>
    </div>
    <link rel="stylesheet" href="/plugins/jedate/jedate.css"/>
    <script src="/plugins/jedate/jedate.min.js"></script>
    <script src="{{ config('global.assets_path') }}js/jquery.validate.min.js"></script>
    <script src="{{ config('global.assets_path') }}js/messages_zh.js"></script>
    <script src="/plugins/layui/layui.js"></script>
    <script src="/plugins/layui/layui_component.js"></script>
    <script src="/js/ajax.js"></script>
    <script>
        function all_select(obj) {
            $('#simple-table').find("input" ).prop('checked',obj.checked);
        }
        function check_all_select(obj) {
            var leng = $('#simple-table').find('input[name="ids[]"]').length;
            var check_leng = $('#simple-table').find('input[name="ids[]"]:checked').length;
            if(leng == check_leng){
                $('#all_check').prop('checked',obj.checked);
            }else{
                $('#all_check').attr('checked',false);
            }
        }
        // 批量处理
        function batch_check(status) {
            var checkeds = $('#simple-table').find('input:checked');
            if(checkeds.length == 0){
                showMessage('未选择记录', 0);
                return false;
            }
            var ids = [];
            $.each(checkeds, function (i, item) {
                ids.push($(this).val());
            })
            var data = {'ids':ids,'status':status.status};
            var url = '{{ route('admin.finance.ajaxCheckGetCash') }}';
            ajaxRequest(data,url,'post');
        }

        function one_check(data) {
            //var data = {'ids':id,'status':status};
            var url = '{{ route('admin.finance.ajaxCheckGetCash') }}';
            ajaxRequest(data,url,'post');
        }
        var start = {
            dateCell: "#start_time",
            format: "YYYY-MM-DD",
            isinitVal: false,
            isTime: false, //isClear:false,
            maxDate: "{{ $where['end_time'] }}",
            minDate: "",
            choosefun: function (datas) {
                end.minDate = datas;
                $("input[name='begin']").val(datas);
            }
        };
        jeDate(start);
        var end = {
            dateCell: "#end_time",
            format: "YYYY-MM-DD",
            isinitVal: false,
            isTime: false, //isClear:false,
            maxDate: "2099-01-01 23:59:59",
            minDate: "{{ $where['start_time'] }}",
            choosefun: function (datas) {
                start.maxDate = datas;
                $("input[name='end']").val(datas);
            }
        };
        jeDate(end);
    </script>
@endsection